if (window.require){
  window.$ele = {
    electron: window.require('electron'),
    fs: window.require('fs'),
    path: window.require('path'),
    util: window.require('util')
  };
}

Array.prototype.last = function(){
  return this[this.length - 1];
};

Array.prototype.remove = function(it){
  const index = this.indexOf(it);
  if (index > -1){
    return this.splice(index, 1);
  }
};

export const uniqueArr = (arr:any[]) => {
  const newArr:any[] = [];
  const set = new Set();
  arr.forEach(i => {
    if (!set.has(i)){
      set.add(i);
      newArr.push(i);
    }
  });
  return newArr;
};

Array.prototype.distinct = function(){
  return uniqueArr(this);
};

Set.prototype.addAll = function(set:any[]|Set<any>){
  set.forEach((i:any) => {
    this.add(i);
  });
  return this;
};